src: Only use local VFS - this avoids hitting up the session bus
authorColin Walters <walters@verbum.org>
Mon, 17 Oct 2011 19:55:06 +0000 (15:55 -0400)
committerColin Walters <walters@verbum.org>
Mon, 17 Oct 2011 19:55:06 +0000 (15:55 -0400)
We are designed to run in the "unix model" of being forked a lot, so
startup time matters a lot, and hitting the session bus adds
unnecessary DBus traffic, shows up in strace etc.

It's a microoptimization I admit.

src/ht-builtin-init.c
src/libhacktree/hacktree-repo.c
src/libhtutil/ht-gio-utils.c
src/libhtutil/ht-gio-utils.h

index 6c22f4df124f6bcb82f073972054f9697048ff0a..4dc2d7f093bca9a667c6a3f0c6aef7ace8acea1e 100644 (file)
@@ -52,7 +52,7 @@ hacktree_builtin_init (int argc, char **argv, const char *prefix, GError **error
     repo_path = ".";
 
   htdir_path = g_build_filename (repo_path, HACKTREE_REPO_DIR, NULL);
-  htdir = g_file_new_for_path (htdir_path);
+  htdir = ht_util_new_file_for_path (htdir_path);
 
   if (!g_file_make_directory (htdir, NULL, error))
     goto out;
index 6781d25da08981b770ec32d458f8365b3f60d378..90b34ad7f10bd6fe5b9d6a93790e261bd5a9201b 100644 (file)
@@ -132,7 +132,7 @@ hacktree_repo_constructor (GType                  gtype,
 
   g_assert (priv->path != NULL);
   
-  priv->repo_file = g_file_new_for_path (priv->path);
+  priv->repo_file = ht_util_new_file_for_path (priv->path);
   priv->head_ref_path = g_build_filename (priv->path, HACKTREE_REPO_DIR, "HEAD", NULL);
   priv->objects_path = g_build_filename (priv->path, HACKTREE_REPO_DIR, "objects", NULL);
 
@@ -1534,7 +1534,7 @@ hacktree_repo_iter_objects (HacktreeRepo  *self,
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
   g_return_val_if_fail (priv->inited, FALSE);
 
-  objectdir = g_file_new_for_path (priv->objects_path);
+  objectdir = ht_util_new_file_for_path (priv->objects_path);
   enumerator = g_file_enumerate_children (objectdir, "standard::name,standard::type,unix::*", 
                                           G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                           NULL, 
index 615699a4ee054f6f48eedcbe2129d3765e66bdfd..c49b8832407defff8de714ee1cbd93b913e8f0ad 100644 (file)
@@ -105,3 +105,10 @@ ht_util_read_file_noatime (GFile *file, GCancellable *cancellable, GError **erro
   g_free (path);
   return ret;
 }
+
+/* Like g_file_new_for_path, but only do local stuff, not GVFS */
+GFile *
+ht_util_new_file_for_path (const char *path)
+{
+  return g_vfs_get_file_for_path (g_vfs_get_local (), path);
+}
index 388a654450bc444a53549c5e877d9a4fc9eed8c7..c7342c4e870309a5adc705d80c4c04dae32ceaef 100644 (file)
@@ -26,6 +26,8 @@
 
 G_BEGIN_DECLS
 
+GFile *ht_util_new_file_for_path (const char *path);
+
 gboolean ht_util_ensure_directory (const char *path, gboolean with_parents, GError **error);
 
 char * ht_util_get_file_contents_utf8 (const char *path, GError    **error);